package com.shop.wk.service.impl;

import com.shop.wk.service.FilterService;
import com.shop.wk.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 日月星辰
 * @date 2020/12/26 20:34
 * @description
 */
@Service
public class FilterServiceImpl implements FilterService {

  private static final String GATEWAY = "g";
  private static final String BLACKLIST_IP_HASH_LIST = "black";
  private static final String WHITELIST_URI_HASH_LIST = "white";

  @Autowired
  private RedisService redisService;

  @Override
  public boolean isBlackList(String ip) {
    return redisService.hasHash(BLACKLIST_IP_HASH_LIST, ip);
  }

  @Override
  public boolean uriIsWihteList(String path) {
    return redisService.hasHash(WHITELIST_URI_HASH_LIST, path);
  }
}
